home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1997 February / macformat-047.iso / Demos / Simpsons Cartoon Studio™ Demo / Simpsons / Support / dlogdata / open.Dxr / 00002_openDialogBox parent.ls < prev    next >
Encoding:
Text File  |  1996-08-16  |  6.0 KB  |  200 lines

  1. property openButton, deleteButton, cancelButton, importButton, fileIndex, theNumberOfFiles, theContentList
  2. global openDialogBox, theScrollBar, fileMgr, toonDataFileList, PCflag, creditsEdited
  3.  
  4. on birth me
  5.   set openButton to 2
  6.   set deleteButton to 3
  7.   set cancelButton to 4
  8.   set importButton to 5
  9.   puppetSprites(openButton, importButton, 1)
  10.   puppetSprites(20, 33, 1)
  11.   puppetSprite(48, 1)
  12.   set creditsEdited to 0
  13.   if PCflag then
  14.     set the textFont of field "filename field" to "Arial"
  15.     set the textSize of field "filename field" to 10
  16.     set the textStyle of field "filename field" to "bold"
  17.     set the textFont of field "credits field" to "Arial"
  18.     set the textSize of field "credits field" to 9
  19.     set the textStyle of field "credits field" to "bold"
  20.     set the textFont of field "file info field" to "Arial"
  21.     set the textSize of field "file info field" to 9
  22.     set the textStyle of field "file info field" to "bold"
  23.   else
  24.     set the textFont of field "filename field" to "Geneva"
  25.     set the textSize of field "filename field" to 10
  26.     set the textStyle of field "filename field" to "bold"
  27.     set the textFont of field "credits field" to "Geneva"
  28.     set the textSize of field "credits field" to 9
  29.     set the textStyle of field "credits field" to "bold"
  30.     set the textFont of field "file info field" to "Geneva"
  31.     set the textSize of field "file info field" to 9
  32.     set the textStyle of field "file info field" to "bold"
  33.   end if
  34.   return me
  35. end
  36.  
  37. on init me
  38.   set theNumberOfFiles to count(toonDataFileList)
  39.   set fileIndex to theNumberOfFiles
  40.   set toonDataFileInfo to getAt(toonDataFileList, fileIndex)
  41.   set the text of field "filename field" to getAt(toonDataFileInfo, 1)
  42.   set the text of field "credits field" to getAt(toonDataFileInfo, 2)
  43.   set theContentList to getAt(toonDataFileInfo, 4)
  44.   showThumbnails(me)
  45.   if theNumberOfFiles > 1 then
  46.     enable(theScrollBar)
  47.   else
  48.     disable(theScrollBar)
  49.   end if
  50.   updateFileInfoField(me)
  51.   updateStage()
  52. end
  53.  
  54. on updateFileInfoField me
  55.   put "Cartoon" && fileIndex && "out of" && theNumberOfFiles into field "file info field"
  56. end
  57.  
  58. on handleButton me, whichSprite
  59.   if hiliteButton(whichSprite) then
  60.     if whichSprite = openButton then
  61.       openCartoon(me)
  62.     else
  63.       if whichSprite = deleteButton then
  64.         deleteCartoon(me)
  65.       else
  66.         if whichSprite = importButton then
  67.           importCartoon(me)
  68.         else
  69.           if whichSprite = cancelButton then
  70.             hide(me)
  71.           end if
  72.         end if
  73.       end if
  74.     end if
  75.   end if
  76. end
  77.  
  78. on incrementFilePointer me
  79.   if fileIndex < count(toonDataFileList) then
  80.     set fileIndex to fileIndex + 1
  81.     set toonDataFileInfo to getAt(toonDataFileList, fileIndex)
  82.     set the text of field "filename field" to getAt(toonDataFileInfo, 1)
  83.     set the text of field "credits field" to getAt(toonDataFileInfo, 2)
  84.     set theContentList to getAt(toonDataFileInfo, 4)
  85.     showThumbnails(me)
  86.     updateFileInfoField(me)
  87.     update(theScrollBar)
  88.     updateStage()
  89.   end if
  90. end
  91.  
  92. on decrementFilePointer me
  93.   if fileIndex > 1 then
  94.     set fileIndex to fileIndex - 1
  95.     set toonDataFileInfo to getAt(toonDataFileList, fileIndex)
  96.     set the text of field "filename field" to getAt(toonDataFileInfo, 1)
  97.     set the text of field "credits field" to getAt(toonDataFileInfo, 2)
  98.     set theContentList to getAt(toonDataFileInfo, 4)
  99.     showThumbnails(me)
  100.     updateFileInfoField(me)
  101.     update(theScrollBar)
  102.     updateStage()
  103.   end if
  104. end
  105.  
  106. on hide me
  107.   set the modal of openDialogBox to 0
  108.   forget(openDialogBox)
  109. end
  110.  
  111. on openCartoon me
  112.   tell the stage
  113.     readToonData(fileMgr, fileIndex)
  114.   end tell
  115.   hide(me)
  116. end
  117.  
  118. on deleteCartoon me
  119.   tell the stage
  120.     deleteCartoon(fileMgr, fileIndex)
  121.   end tell
  122.   hide(me)
  123. end
  124.  
  125. on importCartoon me
  126.   tell the stage
  127.     importToonData(fileMgr)
  128.   end tell
  129.   hide(me)
  130. end
  131.  
  132. on update me, direction
  133.   if ((fileIndex + direction) <> 0) and ((fileIndex + direction) <= theNumberOfFiles) then
  134.     set fileIndex to fileIndex + direction
  135.     set toonDataFileInfo to getAt(toonDataFileList, fileIndex)
  136.     set the text of field "filename field" to getAt(toonDataFileInfo, 1)
  137.     set the text of field "credits field" to getAt(toonDataFileInfo, 2)
  138.     set theContentList to getAt(toonDataFileInfo, 4)
  139.     showThumbnails(me)
  140.     updateFileInfoField(me)
  141.     update(theScrollBar)
  142.   end if
  143. end
  144.  
  145. on getCurrentFileNumber
  146.   return fileIndex
  147. end
  148.  
  149. on getTheNumberOfFiles
  150.   return theNumberOfFiles
  151. end
  152.  
  153. on showThumbnails me
  154.   set positionTable to [[54, 54], [90, 54], [90, 90], [54, 90], [18, 90], [18, 54], [18, 18], [54, 18], [90, 18], [126, 18], [126, 54], [126, 90]]
  155.   set bgdThumbnail to getAt(theContentList, 1)
  156.   if bgdThumbnail = EMPTY then
  157.     set bgdThumbnail to "DEFAULT"
  158.   end if
  159.   set bgdThumbnail to bgdThumbnail & ".thumb"
  160.   set the loc of sprite 20 to point(94, 84)
  161.   set the castNum of sprite 20 to the number of cast bgdThumbnail
  162.   set listOfCharacters to getAt(theContentList, 2)
  163.   set thumbnailSprite to 21
  164.   set numberOfCharacters to count(listOfCharacters)
  165.   repeat with i = 1 to 12
  166.     if i <= numberOfCharacters then
  167.       set castThumbnail to getAt(listOfCharacters, i)
  168.       set thePoints to getAt(positionTable, i)
  169.       set x to the left of sprite 20 + getAt(thePoints, 1)
  170.       set y to the top of sprite 20 + getAt(thePoints, 2)
  171.       set the loc of sprite thumbnailSprite to point(x, y)
  172.       set the castNum of sprite thumbnailSprite to the number of cast (castThumbnail & ".thumb")
  173.     else
  174.       set the loc of sprite thumbnailSprite to point(-1000, 18)
  175.     end if
  176.     set thumbnailSprite to thumbnailSprite + 1
  177.   end repeat
  178. end
  179.  
  180. on clickedPreview me
  181.   if creditsEdited then
  182.     updateCredits(me)
  183.     set creditsEdited to 0
  184.   else
  185.     openCartoon(me)
  186.   end if
  187. end
  188.  
  189. on updateCredits me
  190.   set toonDataFileInfo to getAt(toonDataFileList, fileIndex)
  191.   set oldCartoonCredits to getAt(toonDataFileInfo, 2)
  192.   set newCartoonCredits to the text of field "credits field"
  193.   setAt(getAt(toonDataFileList, fileIndex), 2, newCartoonCredits)
  194.   if newCartoonCredits <> oldCartoonCredits then
  195.     tell the stage
  196.       updateToonData(fileMgr, fileIndex, newCartoonCredits, #open)
  197.     end tell
  198.   end if
  199. end
  200.